package com.example.librarymanagementsystembackend.borrowingmanagement.aspect;

import com.example.librarymanagementsystembackend.borrowingmanagement.service.BorrowingRecordService;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class SystemSettingsAspect {
    @Autowired
    private BorrowingRecordService borrowingRecordService;

    /**
     * 用于每次调用时更新 BorrowingRecordService 的 maxBorrowLimit borrowPeriodDays dailyOverdueFine字段
     */
    // 拦截所有标记@LoadSystemSettings的方法
    @Before("@annotation(com.example.librarymanagementsystembackend.borrowingmanagement.annotation.LoadSystemSettings)")
    public void loadSettingsBeforeExecution() {
        borrowingRecordService.updateSettingsFromSystemService();
    }
}